var express = require('express');
const db = require("./db")
var router = express.Router();
var multer = require('multer');
 //导入连个内置模块
const path= require('path')
const fs=require('fs')
// 设置图片的位置
var objMulter=multer({dest: './public/images'}); 
router.use(objMulter.any());  
/* GET users listing. */
router.get('/', function(req, res, next) {
  res.send('respond with a resource');
});


//查询商品
router.get('/searchAll', function (req, res, next) {
  let p = new Promise((resolve, reject) => {
    let sql = `select * from image where 1`;
    db(sql, (err, data) => {
      data ? resolve(data) : reject(err)
    })
  })
  p.then((data) => {
    res.send(data)
  })

});


module.exports = router;
